package it.uniroma2.art.coda.structures.depends;

import it.uniroma2.art.coda.projectionrule.ProjectionRule;

/**
 * This abstract class is the generic object representing some dependency between a projection rule and
 * another projection rule
 * 
 * @author Andrea Turbati
 * 
 */
public abstract class DependencyObject {
	String ruleId;
	ProjectionRule projRule = null;
	String dependsOnType;
	private boolean isExtDepADependsOn; // useful only if hasExternalReference is true
	private boolean isDynamicDependency;

	/**
	 * @param ruleId
	 *            the projection rule id that it is ponted by this dependency
	 * @param dependsOnType
	 *            the dependency type
	 * @param isExtDepADependsOn
	 *            true if this dependency is a dependsOn, false otherwise
	 */
	public DependencyObject(String ruleId, String dependsOnType, boolean isExtDepADependsOn) {
		this.ruleId = ruleId;
		this.dependsOnType = dependsOnType;
		this.isExtDepADependsOn = isExtDepADependsOn;
		this.isDynamicDependency = false;
	}
	
	public DependencyObject(String ruleId, String dependsOnType, boolean isExtDepADependsOn, boolean isDynamicDependency) {
		this.ruleId = ruleId;
		this.dependsOnType = dependsOnType;
		this.isExtDepADependsOn = isExtDepADependsOn;
		this.isDynamicDependency = isDynamicDependency;
	}

	/**
	 * Get the projection rule id of the object of this dependency
	 * 
	 * @return the projection rule id of the object of this dependency
	 */
	public String getRuleId() {
		return ruleId;
	}

	/**
	 * Get the dependency type
	 * 
	 * @return the dependency type
	 */
	public String getDependsOnType() {
		return dependsOnType;
	}

	/**
	 * Check if this dependency is a dependsOn one
	 * 
	 * @return true if this dependency is a depedensOn, false otherwise
	 */
	public boolean isExtDepADependsOn() {
		return isExtDepADependsOn;
	}

	/**
	 * Set the projection rule that is the object of this dependency (not the subject), it is null 
	 * in the dynamic dependency
	 * 
	 * @param projRule
	 *            the projection rule that is the object of this dependency (not the subject), it is 
	 *            null in the dynamic dependency
	 */
	public void setProjRule(ProjectionRule projRule) {
		this.projRule = projRule;
	}

	/**
	 * Get the projection rule that is the object of this dependency
	 * 
	 * @return the projection rule that is the object of this dependency
	 */
	public ProjectionRule getProjRule() {
		return projRule;
	}
	
	/**
	 * Check if this is a dynamic dependency. Only external dependency can be dynamic
	 * 
	 * @return true if this is a dynamic dependency, false otherwise
	 */
	public boolean isDynamicDependency(){
		return isDynamicDependency;
	}

}
